#if !defined(_AEVENT_H_)
#define _AEVENT_H_

#include "AObject.h"

typedef enum enumEventType
{
	ET_Null,
	ET_Touch,
	ET_Command,
	ET_System,
}
EEventType;

class CAEvent : public CAObject
{
protected:
	EEventType _type;
	bool _bNoSprites;
public:
	CAEvent()
	{
		_type = ET_Null;
		_bNoSprites = false;
		autorelease();
	}
	inline EEventType type() const 
	{ 
		_Assert(ET_Null != _type);
		return _type; 
	}
	inline bool isNoSprites() const
	{
		return _bNoSprites;
	}
};

typedef enum tagTouchState 
{
	kTouchStateGrabbed,
	kTouchStateMoving,
	kTouchStateUngrabbed
} 
ETouchState; 

typedef enum enumSenderType
{
	ST_Sprite,
	ST_Layer,
	ST_Stage,
}
ESenderType;
class CAEventTouch : public CAEvent
{
protected:
	ETouchState _ts;
	CCPoint _pt;
	CCPoint _ptPrev;
public:
	CAEventTouch(ETouchState ts, const CCPoint& pt, const CCPoint& ptPrev);

	inline ETouchState state() const { return _ts; }
	inline const CCPoint& pt() const { return  _pt; }
	inline const CCPoint& ptPrev() const { return  _ptPrev; }
};


typedef enum enumSystemEvent
{
	SE_Pause,
	SE_Resume,
}
ESystemEvent;
class CAEventSystem : public CAEvent
{
protected:
	ESystemEvent _evt;
	void* _data;
public:
	CAEventSystem(ESystemEvent evt, void* data);

	inline ESystemEvent evt() const { return _evt; }
	inline void* data() const { return  _data; }
};

class CASprite;
class CAStageLayer;
class CAStage;
class CAEventCommand : public CAEvent
{
protected:
	CCObject* _sender;
	ESenderType _sendertype;
	CAString _command;
	void* _pdata;
public:
	CAEventCommand(CASprite* sender, const CAString& command, void* pdata = null)
	{
		_type = ET_Command;
		_sender = (CCObject*)sender;
		_sendertype = ST_Sprite;
		_command = command;
		_pdata = pdata;
	}
	CAEventCommand(CAStageLayer* sender, const CAString& command, void* pdata = null)
	{
		_type = ET_Command;
		_sender = (CCObject*)sender;
		_sendertype = ST_Layer;
		_command = command;
		_pdata = pdata;
	}
	CAEventCommand(CAStage* sender, const CAString& command, void* pdata = null)
	{
		_type = ET_Command;
		_sender = (CCObject*)sender;
		_sendertype = ST_Stage;
		_command = command;
		_pdata = pdata;
	}

	inline const CAString& command() const { return _command; }
	inline ESenderType getSenderType() const { return _sendertype; }
	inline CCObject* sender() { return _sender; }
	inline void* userdata() { return _pdata; }
};

#endif //_AEVENT_H_
